package com.guijq.codesegment.tree;

import java.util.ArrayList;
import java.util.List;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

/**
 * @author yangjf
 * @version 0.1.0
 * @time 2018/8/13/013
 */
public class TestTreeDrive {
    private static Gson gson =  new GsonBuilder()
            .setDateFormat("yyyy-MM-dd HH:mm:ss")
            .create();

    public static void main(String[] args) {
        List<EquipmentModelTreeNode2Vo>  equipmentModelTreeNode2Vos = new ArrayList<>();
        List<EquipmentITreeNode2Vo> equipmentTreeNode2Vos = new ArrayList<>();

        equipmentModelTreeNode2Vos.add(new EquipmentModelTreeNode2Vo( 1,null,1, "EMC001","设备类型001","",1));
        equipmentModelTreeNode2Vos.add(new EquipmentModelTreeNode2Vo( 2,1,1, "EMC003","设备类型003","",1));
        equipmentModelTreeNode2Vos.add(new EquipmentModelTreeNode2Vo( 3,1,1, "EMC004","设备类型004","",1));
        equipmentModelTreeNode2Vos.add(new EquipmentModelTreeNode2Vo( 4,3,1, "EMC005","设备类型005","",1));
        equipmentModelTreeNode2Vos.add(new EquipmentModelTreeNode2Vo( 5,4,1, "EMC006","设备类型006","",1));
        equipmentModelTreeNode2Vos.add(new EquipmentModelTreeNode2Vo( 6,1,1, "EMC007","设备类型007","",1));
        equipmentModelTreeNode2Vos.add(new EquipmentModelTreeNode2Vo( 7,1,1, "string12701","string","",1));
        equipmentModelTreeNode2Vos.add(new EquipmentModelTreeNode2Vo( 9,null,1, "default_equipment_model","默认设备类型","",1));
        equipmentModelTreeNode2Vos.add(new EquipmentModelTreeNode2Vo( 10,null,1, "66f95f31-a809-45a3-99d9-ba94c8ae432e","类型4","",1));
        equipmentModelTreeNode2Vos.add(new EquipmentModelTreeNode2Vo( 11,10,1, "1a7a22de-2898-43e4-9749-0551bbaa34e9","子类型","",1));
        equipmentModelTreeNode2Vos.add(new EquipmentModelTreeNode2Vo( 12,null,1, "1e409b05-5c62-4172-9a68-5d31cd071ff8","冲压","",1));
        equipmentModelTreeNode2Vos.add(new EquipmentModelTreeNode2Vo( 13,null,1, "40992ad7-6d7e-45a0-9c06-bebe24f99abb","类型3","",1));
        equipmentModelTreeNode2Vos.add(new EquipmentModelTreeNode2Vo( 14,null,1, "04df8086-b6d1-4363-92ca-876e630e5887","类型1","",1));
        equipmentModelTreeNode2Vos.add(new EquipmentModelTreeNode2Vo( 15,14,1, "be3dd576-98a2-433e-8434-f6a18dff66a7","类型2","",1));

        equipmentTreeNode2Vos.add(new EquipmentITreeNode2Vo(1,"ZZ01","铸造01",2,2));
        equipmentTreeNode2Vos.add(new EquipmentITreeNode2Vo(2,"ZZ02","铸造02",2,2));
        equipmentTreeNode2Vos.add(new EquipmentITreeNode2Vo(3,"ZZ03","铸造03",2,2));
        equipmentTreeNode2Vos.add(new EquipmentITreeNode2Vo(4,"0000000000000","2323",9,2));
        equipmentTreeNode2Vos.add(new EquipmentITreeNode2Vo(5,"ZZ01","铸造01",9,2));
        equipmentTreeNode2Vos.add(new EquipmentITreeNode2Vo(6,"ZZ01","铸造01",9,2));
        equipmentTreeNode2Vos.add(new EquipmentITreeNode2Vo(7,"ZZ01","铸造01",9,2));



        // TODO: 2018/8/13/013  set level

        List<ITreeNode> a = new ArrayList<>();
        a.addAll(equipmentModelTreeNode2Vos);
        a.addAll(equipmentTreeNode2Vos);
        Tree t = new Tree(a);

        List<TreeNodeVo> treeNodeVos = TreeNodeUtil.transFromTreeNodeBo(t.getRoot(), "");

        System.out.println(gson.toJson(treeNodeVos));
        System.out.println(gson.toJson(t.getRoot()));
    }
}
